package com.xjrsoft.module.customer.erp_model.goodsCategoryManage.service.impl;
import com.baomidou.dynamic.datasource.annotation.DS;
import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.xjrsoft.core.tool.utils.StringUtil;
import com.xjrsoft.module.customer.erp_model.goodsCategoryManage.entity.ErpGoodscategory;
import com.baomidou.mybatisplus.core.toolkit.IdWorker;
import com.xjrsoft.module.customer.erp_model.goodsCategoryManage.dto.ErpGoodscategoryListDto;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.xjrsoft.common.page.ConventPage;
import com.xjrsoft.common.page.PageOutput;
import com.xjrsoft.module.customer.erp_model.goodsCategoryManage.mapper.ErpGoodscategoryMapper;
import com.xjrsoft.module.customer.erp_model.goodsCategoryManage.service.IErpGoodscategoryService;
import com.xjrsoft.core.mp.base.BaseService;
import lombok.AllArgsConstructor;
import org.springframework.stereotype.Service;
import com.baomidou.mybatisplus.core.metadata.IPage;

/**
 *  服务实现类
 *
 * @author pp
 * @since 2021-09-23
 */
@Service
@AllArgsConstructor
public class ErpGoodscategoryServiceImpl extends BaseService<ErpGoodscategoryMapper, ErpGoodscategory> implements IErpGoodscategoryService {


	@Override
	public IPage<ErpGoodscategory> getPageList(ErpGoodscategoryListDto pageListDto) {
		Wrapper<ErpGoodscategory> wrapper = Wrappers.<ErpGoodscategory>query().lambda()				.like(!StringUtil.isEmpty(pageListDto.getF_EnCode()), ErpGoodscategory::getFEncode, pageListDto.getF_EnCode())
				.like(!StringUtil.isEmpty(pageListDto.getF_FullName()), ErpGoodscategory::getFFullname, pageListDto.getF_FullName());
		return this.page(ConventPage.getPage(pageListDto), wrapper);
	}

	@Override
	public String addErpGoodscategory(ErpGoodscategory erpGoodscategory) {
		String erpGoodscategoryId = IdWorker.get32UUID();
		erpGoodscategory.setFId(erpGoodscategoryId);
		boolean isSuccess = this.save(erpGoodscategory);
		return isSuccess ? erpGoodscategoryId : null;
	}

	@Override
	public boolean updateErpGoodscategory(String id, ErpGoodscategory erpGoodscategory) {
		erpGoodscategory.setFId(id);
		return this.updateById(erpGoodscategory);
	}

}
